package com.gjh.springcloud.alibaba.controller;

import com.gjh.springcloud.alibaba.serivce.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
@RestController
public class OrderNacosController {
    @Resource
    private PaymentService paymentService;

    @Resource
    private RestTemplate restTemplate;

    @Value("${service-url.nacos-user-service}")
    private String serverURL;

    @GetMapping(value = "consumerFeign/payment/nacos/{id}")
    public String getPaymentFeign(@PathVariable("id") Integer id)
    {
        return paymentService.getPayment(id);
    }

    @GetMapping(value = "consumer/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id)
    {
        return restTemplate.getForObject(serverURL+"/payment/nacos/"+id,String.class);
    }
}
